import { TypeOrmModule } from '@nestjs/typeorm';
import { ThrottlerModule } from '@nestjs/throttler';

export const MySqlOrmModule = TypeOrmModule.forRoot({
  type: 'mysql',
  host: 'localhost',
  port: 3306,
  username: 'root',
  password: 'Rr2872..',
  database: 'demo',
  autoLoadEntities: true,
  // entities: [User],
  synchronize: true,
  // 开启缓存,默认是缓存1秒
  cache: {
    duration: 3000, // 3000表示3秒
  },
});

// https://docs.nestjs.com/security/rate-limiting
export const MyThrottlerModule = ThrottlerModule.forRoot([
  {
    ttl: 60 * 1000,
    limit: 10,
  },
]);
